Python modules with headless scripting

How do I install packages like pandas or numpy to use it with my KS headless script? I was not able to find a way to do that.

You need an installation of the right python version and the setting to use the local python in the preferences.
Then you can call for the module in the script.

For example:

from collections.abc import Iterable
import math
import shutil
import subprocess
import os

try:
import configparser
except ImportError:
subprocess.call([“python”, “-m”, “pip”, “install”, “configparser”])
print(“Configparser installed”)
finally:
import configparser

try:
from PIL import Image
except ImportError:
subprocess.call([“python”, “-m”, “pip”, “install”, “Pillow”])
print(“Pillow installed”)
finally:
from PIL import Image

CheerEO
Marco

1 Like

Here’s the answer of Perplexity AI attached as Word Doc:
Installing Packages like Pandas or NumPy for KeySh.docx (116.6 KB) export